#include "all.h"
#include <mutex>

libco::CoMutex mu;
// std::mutex mu;
libco::WaitGroup wg;
int count = 0;

int main() {
    libco::SetThreadName("thread_main");
    LIBCO_LOG << "Main Begin";
    for(int i=0; i<100; ++i) {
        wg.add();
        co_func([](){
            co_yield
            mu.lock();
            ++count;
            LIBCO_LOG_DEBUG << "count = " << count;
            mu.unlock();
            co_yield
            wg.done();
        });
    }
    wg.wait();
    LIBCO_LOG_INFO << "final count = " << count;
}